from django.db import models


# Create your models here.
class RedisAppModel(models.Model):
    # 定义实例模型-包含字段 实例名称、数据库类型、实例类型、实例连接、实例端口、实例用户名称、创建时间、修改时间
    # 字段定义
    name = models.CharField(max_length=100, verbose_name="实例名称")
    db_type = models.CharField(max_length=50, verbose_name="数据库类型")
    instance_type = models.CharField(max_length=50, verbose_name="实例类型")
    host = models.CharField(max_length=200, verbose_name="实例连接")
    port = models.PositiveIntegerField(verbose_name="实例端口")
    user_name = models.CharField(max_length=50, verbose_name="实例用户名称")
    password = models.CharField(max_length=100, verbose_name="实例密码")
    created_at = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    updated_at = models.DateTimeField(auto_now=True, verbose_name="修改时间")

    class Meta:
        verbose_name = "实例配置"
        verbose_name_plural = verbose_name
        ordering = ['-created_at']

    def __str__(self):
        return self.name
